//
//  ListView.swift
//  SwiftUIDemo
//
//  Created by 陈旺 on 2022/2/14.
//

import SwiftUI

struct ListView: View {
    
    @State var show = false
    
    var body: some View {
        VStack {
            ScrollView(.horizontal, showsIndicators: false) {
                HStack(spacing: 20) {
                    ForEach(0..<3) { item in
                        Button(action: {
                            self.show.toggle()
                        },label: {
                            ItemView()
                        }).sheet(isPresented: $show) {
                            
                        } content: {
                            ContentView()
                        }

                    }
                    
                }
                .padding(.bottom, 30.0)
                .padding(.horizontal)
            }
            Spacer()
        }
        .background(.white)
    }
}

struct ListView_Previews: PreviewProvider {
    static var previews: some View {
        ListView()
            .previewDevice("iPhone 11")
    }
}


struct ItemView: View {
    var body: some View {
        VStack() {
            HStack {
                Text("Build an app with SwiftUI")
                    .font(.title)
                    .fontWeight(.medium)
                    .foregroundColor(.white)
                    .multilineTextAlignment(.leading)
                    .lineLimit(4)
                    .padding(.trailing, 40)
                Spacer()
            }
            .padding(.top, 20)
            .padding(.leading, 20)
            Spacer()
        }
        .frame(width: 200, height: 300)
        .background(.blue)
        .cornerRadius(20)
        .shadow(color: .blue, radius: 10, x: 4, y: 4)
    }
}
